﻿
namespace BEGDC.PreContract.DAL
{
    using System;
    using System.Collections.Generic;
    using Castle.ActiveRecord;
    using NHibernate.Expression;


    [ActiveRecord]
    public partial class PreContractInfo : ActiveRecordBase<PreContractInfo>
    {
		#region Const Definition
		
		public const string CONST_PreContractID							= "PreContractID";
		public const string CONST_PreContractNo							= "PreContractNo";
		public const string CONST_StatusID								= "StatusID";
		public const string CONST_TypeID								= "TypeID";
		public const string CONST_ProductID								= "ProductID";
		public const string CONST_PromisedDate							= "PromisedDate";
		public const string CONST_CEWPromised							= "CEWPromised";
		public const string CONST_OrionPrice							= "OrionPrice";
		public const string CONST_SalePrice								= "SalePrice";
		public const string CONST_SignDue								= "SignDue";
		public const string CONST_SignActual							= "SignActual";
		public const string CONST_ContractName							= "ContractName";
		public const string CONST_ERPReceived							= "ERPReceived";
		public const string CONST_OrionNo								= "OrionNo";
		public const string CONST_Delivered								= "Delivered";
		public const string CONST_CurrentSituation						= "CurrentSituation";
		public const string CONST_BlackDate								= "BlackDate";
		public const string CONST_TradeMonth							= "TradeMonth";
		public const string CONST_ModifiedDate							= "ModifiedDate";
		public const string CONST_ACRNo									= "ACRNo";
		public const string CONST_ASBorLucent							= "ASBorLucent";
		public const string CONST_Applicant								= "Applicant";
		public const string CONST_ApplicantEmail						= "ApplicantEmail";
		public const string CONST_Principal								= "Principal";
		public const string CONST_PrincipalEmail						= "PrincipalEmail";
		public const string CONST_ProvinceID							= "ProvinceID";
		public const string CONST_CATID									= "CATID";
		public const string CONST_BDID									= "BDID";
		public const string CONST_CustomerName							= "CustomerName";
		public const string CONST_CustomField01							= "CustomField01";
		public const string CONST_CustomField02							= "CustomField02";
		public const string CONST_CustomField03							= "CustomField03";
		public const string CONST_CustomField04							= "CustomField04";
		public const string CONST_DeliveryPercent						= "DeliveryPercent";
		public const string CONST_AdvancedContract						= "AdvancedContract";
		public const string CONST_IsRisk								= "IsRisk";
        public const string CONST_DeliveryDate                          = "DeliveryDate";
        public const string CONST_Flag                                  = "Flag";
        public const string CONST_IsDelay                               = "IsDelay";
        public const string CONST_AdjustID                              = "AdjustID";
        public const string CONST_SparePrice                            = "SparePrice";
        public const string CONST_CFIPrice                              = "CFIPrice";
        public const string CONST_DeliveryPlan                          = "DeliveryPlan";
        public const string CONST_UpdateReason                          = "UpdateReason";
        public const string CONST_AOGDate = "AOGDate";
        public const string CONST_TransferHistoryInfo = "TransferHistoryInfo";
        public const string CONST_SpecialApprove = "SpecialApprove";
        public const string CONST_DeadlineOfTrying = "DeadlineOfTrying";

		#endregion
		
        #region Member Variables
        // Primary Key
        private System.Int32 _preContractID;
        
        // Non Key
        private System.String _preContractNo;
        private Nullables.NullableDateTime _promisedDate;
        private Nullables.NullableDecimal _cEWPromised;
        private Nullables.NullableDecimal _orionPrice;
        private Nullables.NullableDecimal _salePrice;
        private Nullables.NullableDateTime _signDue;
        private Nullables.NullableDateTime _signActual;
        private System.String _contractName;
        private Nullables.NullableDateTime _eRPReceived;
        private System.String _orionNo;
        private System.Boolean _delivered;
        private System.String _currentSituation;
        private Nullables.NullableDateTime _blackDate;
        private Nullables.NullableDateTime _tradeMonth;
        private Nullables.NullableDateTime _modifiedDate;
        private System.String _aCRNo;
        private System.Boolean _aSBorLucent;
        private System.String _applicant;
        private System.String _applicantEmail;
        private System.String _principal;
        private System.String _principalEmail;
        private System.String _customerName;
        private System.String _customField01;
        private System.String _customField02;
        private System.String _customField03;
        private System.String _customField04;
        private Nullables.NullableDecimal _deliveryPercent;
        private System.String _advancedContract;
        private System.Boolean _isRisk;
        private System.Boolean _isDelay;
        private Nullables.NullableDateTime _deliveryDate;
        private Nullables.NullableInt16 _flag;

        private Nullables.NullableDecimal _sparePrice;
        private Nullables.NullableDecimal _cfiPrice;
        private System.String _deliveryPlan;
        private System.String _updateReason;
        private Nullables.NullableDateTime _aogDate;
        private System.String _transferHistoryInfo;
        private System.String _specialApprove;
        private Nullables.NullableDateTime _deadlineOfTrying;

        // Parents
        private CAT _cATID;
        private BD _bDID;
        private Province _provinceID;
        private Product _productID;
        private DicItem _statusID;
        private DicItem _typeID;

        private DicItem _adjustID;
        
		

        #endregion

        public PreContractInfo() {
               
        }
        public PreContractInfo(
            System.String preContractNo
            ,Nullables.NullableDateTime promisedDate
            ,Nullables.NullableDecimal cEWPromised
            ,Nullables.NullableDecimal orionPrice
            ,Nullables.NullableDecimal salePrice
            ,Nullables.NullableDateTime signDue
            ,Nullables.NullableDateTime signActual
            ,System.String contractName
            ,Nullables.NullableDateTime eRPReceived
            ,System.String orionNo
            ,System.Boolean delivered
            ,System.String currentSituation
            ,Nullables.NullableDateTime blackDate
            ,Nullables.NullableDateTime tradeMonth
            ,Nullables.NullableDateTime modifiedDate
            ,System.String aCRNo
            ,System.Boolean aSBorLucent
            ,System.String applicant
            ,System.String applicantEmail
            ,System.String principal
            ,System.String principalEmail
            ,System.String customerName
            ,System.String customField01
            ,System.String customField02
            ,System.String customField03
            ,System.String customField04
            ,Nullables.NullableDecimal deliveryPercent
            ,System.String advancedContract
            ,System.Boolean isRisk
            ,Nullables.NullableDateTime deliveryDate
            ,Nullables.NullableInt16 flag
            ,System.Boolean isDelay
            ,Nullables.NullableDecimal sparePrice
            ,Nullables.NullableDecimal cfiPrice
            ,System.String deliveryPlan
            ,System.String updateReason
            , Nullables.NullableDateTime aogDate
            , System.String transferHistoryInfo
            , System.String specialApprove
            , Nullables.NullableDateTime deadlineOfTrying)
            : this()
        {
                
            this._preContractNo = preContractNo; 
            this._promisedDate = promisedDate; 
            this._cEWPromised = cEWPromised; 
            this._orionPrice = orionPrice; 
            this._salePrice = salePrice; 
            this._signDue = signDue; 
            this._signActual = signActual; 
            this._contractName = contractName; 
            this._eRPReceived = eRPReceived; 
            this._orionNo = orionNo; 
            this._delivered = delivered; 
            this._currentSituation = currentSituation; 
            this._blackDate = blackDate; 
            this._tradeMonth = tradeMonth; 
            this._modifiedDate = modifiedDate; 
            this._aCRNo = aCRNo; 
            this._aSBorLucent = aSBorLucent; 
            this._applicant = applicant; 
            this._applicantEmail = applicantEmail; 
            this._principal = principal; 
            this._principalEmail = principalEmail; 
            this._customerName = customerName; 
            this._customField01 = customField01; 
            this._customField02 = customField02; 
            this._customField03 = customField03; 
            this._customField04 = customField04; 
            this._deliveryPercent = deliveryPercent; 
            this._advancedContract = advancedContract; 
            this._isRisk = isRisk;
            this._deliveryDate = deliveryDate;
            this._flag = flag;
            this._isDelay = isDelay;

            this._sparePrice = sparePrice;
            this._cfiPrice = cfiPrice;
            this._deliveryPlan = deliveryPlan;
            this._updateReason = updateReason;
            this._aogDate = aogDate;
            this._transferHistoryInfo = transferHistoryInfo;
            this._specialApprove = specialApprove;
            this._deadlineOfTrying = deadlineOfTrying;
        }
        
        #region Properties
        // Primary Key        
		
		#if (SQLServer)
        [PrimaryKey]
		#else
		[PrimaryKey(PrimaryKeyType.Native, SequenceName = "SEQ_PRECONTRACTINFO_PRECONTRACTID")]
		#endif
        public System.Int32 PreContractID {
            get { return this._preContractID; }
            set {  this._preContractID = value; }
        }
        
        // Non Key
        [Property]
        public System.String PreContractNo {
            get { return this._preContractNo; }
			set { if (value == null) return; if (value.Length > 20) this._preContractNo = value.Substring(0,20); else this._preContractNo = value; }	
        }
        
        [Property]
        public Nullables.NullableDateTime PromisedDate {
            get { return this._promisedDate; }
			set { this._promisedDate = value; }
        }
        
        [Property]
        public Nullables.NullableDecimal CEWPromised {
            get { return this._cEWPromised; }
			set { this._cEWPromised = value; }
        }
        
        [Property]
        public Nullables.NullableDecimal OrionPrice {
            get { return this._orionPrice; }
			set { this._orionPrice = value; }
        }
        
        [Property]
        public Nullables.NullableDecimal SalePrice {
            get { return this._salePrice; }
			set { this._salePrice = value; }
        }
        
        [Property]
        public Nullables.NullableDateTime SignDue {
            get { return this._signDue; }
			set { this._signDue = value; }
        }
        
        [Property]
        public Nullables.NullableDateTime SignActual {
            get { return this._signActual; }
			set { this._signActual = value; }
        }
        
        [Property]
        public System.String ContractName {
            get { return this._contractName; }
			set { if (value == null) return; if (value.Length > 200) this._contractName = value.Substring(0,200); else this._contractName = value; }	
        }
        
        [Property]
        public Nullables.NullableDateTime ERPReceived {
            get { return this._eRPReceived; }
			set { this._eRPReceived = value; }
        }
        
        [Property]
        public System.String OrionNo {
            get { return this._orionNo; }
			set { if (value == null) return; if (value.Length > 200) this._orionNo = value.Substring(0,200); else this._orionNo = value; }	
        }
        
        [Property]
        public System.Boolean Delivered {
            get { return this._delivered; }
			set { this._delivered = value; }
        }
        
        [Property]
        public System.String CurrentSituation {
            get { return this._currentSituation; }
			set { if (value == null) return; if (value.Length > 1000) this._currentSituation = value.Substring(0,1000); else this._currentSituation = value; }	
        }
        
        [Property]
        public Nullables.NullableDateTime BlackDate {
            get { return this._blackDate; }
			set { this._blackDate = value; }
        }
        
        [Property]
        public Nullables.NullableDateTime TradeMonth {
            get { return this._tradeMonth; }
			set { this._tradeMonth = value; }
        }
        
        [Property]
        public Nullables.NullableDateTime ModifiedDate {
            get { return this._modifiedDate; }
			set { this._modifiedDate = value; }
        }
        
        [Property]
        public System.String ACRNo {
            get { return this._aCRNo; }
			set { if (value == null) return; if (value.Length > 20) this._aCRNo = value.Substring(0,20); else this._aCRNo = value; }	
        }
        
        [Property]
        public System.Boolean ASBorLucent {
            get { return this._aSBorLucent; }
			set { this._aSBorLucent = value; }
        }
        
        [Property]
        public System.String Applicant {
            get { return this._applicant; }
			set { if (value == null) return; if (value.Length > 20) this._applicant = value.Substring(0,20); else this._applicant = value; }	
        }
        
        [Property]
        public System.String ApplicantEmail {
            get { return this._applicantEmail; }
			set { if (value == null) return; if (value.Length > 100) this._applicantEmail = value.Substring(0,100); else this._applicantEmail = value; }	
        }
        
        [Property]
        public System.String Principal {
            get { return this._principal; }
			set { if (value == null) return; if (value.Length > 20) this._principal = value.Substring(0,20); else this._principal = value; }	
        }
        
        [Property]
        public System.String PrincipalEmail {
            get { return this._principalEmail; }
			set { if (value == null) return; if (value.Length > 100) this._principalEmail = value.Substring(0,100); else this._principalEmail = value; }	
        }
        
        [Property]
        public System.String CustomerName {
            get { return this._customerName; }
			set { if (value == null) return; if (value.Length > 200) this._customerName = value.Substring(0,200); else this._customerName = value; }	
        }
        
        [Property]
        public System.String CustomField01 {
            get { return this._customField01; }
			set { if (value == null) return; if (value.Length > 500) this._customField01 = value.Substring(0,500); else this._customField01 = value; }	
        }
        
        [Property]
        public System.String CustomField02 {
            get { return this._customField02; }
			set { if (value == null) return; if (value.Length > 500) this._customField02 = value.Substring(0,500); else this._customField02 = value; }	
        }
        
        [Property]
        public System.String CustomField03 {
            get { return this._customField03; }
			set { if (value == null) return; if (value.Length > 500) this._customField03 = value.Substring(0,500); else this._customField03 = value; }	
        }
        
        [Property]
        public System.String CustomField04 {
            get { return this._customField04; }
			set { if (value == null) return; if (value.Length > 500) this._customField04 = value.Substring(0,500); else this._customField04 = value; }	
        }
        
        [Property]
        public Nullables.NullableDecimal DeliveryPercent {
            get { return this._deliveryPercent; }
			set { this._deliveryPercent = value; }
        }
        
        [Property]
        public System.String AdvancedContract {
            get { return this._advancedContract; }
			set { if (value == null) return; if (value.Length > 500) this._advancedContract = value.Substring(0,500); else this._advancedContract = value; }	
        }
        
        [Property]
        public System.Boolean IsRisk {
            get { return this._isRisk; }
			set { this._isRisk = value; }
        }
        [Property]
        public System.Boolean IsDelay
        {
            get { return this._isDelay; }
            set { this._isDelay = value; }
        }
        
        // Parent Relationships
        [BelongsTo("CATID")]
        public CAT CATID {
            get { return this._cATID; }
            set { this._cATID = value; }
        }
        
        [BelongsTo("BDID")]
        public BD BDID {
            get { return this._bDID; }
            set { this._bDID = value; }
        }
        
        [BelongsTo("ProvinceID")]
        public Province ProvinceID {
            get { return this._provinceID; }
            set { this._provinceID = value; }
        }
        
        [BelongsTo("ProductID")]
        public Product ProductID {
            get { return this._productID; }
            set { this._productID = value; }
        }
        
        [BelongsTo("StatusID")]
        public DicItem StatusID {
            get { return this._statusID; }
            set { this._statusID = value; }
        }
        
        [BelongsTo("TypeID")]
        public DicItem TypeID {
            get { return this._typeID; }
            set { this._typeID = value; }
        }
        [Property]
        public Nullables.NullableDateTime DeliveryDate
        {
            get { return this._deliveryDate; }
            set { this._deliveryDate = value; }
        }
        [Property]
        public Nullables.NullableInt16 Flag
        {
            get { return this._flag; }
            set { this._flag = value; }
        }

        [BelongsTo("AdjustID")]
        public DicItem AdjustID
        {
            get { return this._adjustID; }
            set { this._adjustID = value; }
        }

        [Property]
        public Nullables.NullableDecimal SparePrice
        {
            get { return this._sparePrice; }
            set { this._sparePrice = value; }
        }

        [Property]
        public Nullables.NullableDecimal CFIPrice
        {
            get { return this._cfiPrice; }
            set { this._cfiPrice = value; }
        }

        [Property]
        public System.String DeliveryPlan
        {
            get { return this._deliveryPlan; }
            set { if (value == null) return; if (value.Length > 500) this._deliveryPlan = value.Substring(0, 500); else this._deliveryPlan = value; }
        }

        [Property]
        public System.String UpdateReason
        {
            get { return this._updateReason; }
            set { if (value == null) return; this._updateReason = value; }
        }

        [Property]
        public Nullables.NullableDateTime AOGDate
        {
            get { return this._aogDate; }
            set { this._aogDate = value; }
        }

        [Property]
        public System.String TransferHistoryInfo
        {
            get { return this._transferHistoryInfo; }
            set { if (value == null) return; if (value.Length > 500) this._transferHistoryInfo = value.Substring(0, 500); else this._transferHistoryInfo = value; }
        }
        [Property]
        public System.String SpecialApprove
        {
            get { return this._specialApprove; }
            set { if (value == null) return; if (value.Length > 50) this._specialApprove = value.Substring(0, 50); else this._specialApprove = value; }
        }

        [Property]
        public Nullables.NullableDateTime DeadlineOfTrying
        {
            get { return this._deadlineOfTrying; }
            set { this._deadlineOfTrying = value; }
        }

        // Child Relationships
        #endregion
		
		// Clone
		public PreContractInfo Clone()
		{
			PreContractInfo newPreContractInfo = new PreContractInfo();
			
            newPreContractInfo.PreContractNo = this._preContractNo; 
            newPreContractInfo.PromisedDate = this._promisedDate; 
            newPreContractInfo.CEWPromised = this._cEWPromised; 
            newPreContractInfo.OrionPrice = this._orionPrice; 
            newPreContractInfo.SalePrice = this._salePrice; 
            newPreContractInfo.SignDue = this._signDue; 
            newPreContractInfo.SignActual = this._signActual; 
            newPreContractInfo.ContractName = this._contractName; 
            newPreContractInfo.ERPReceived = this._eRPReceived; 
            newPreContractInfo.OrionNo = this._orionNo; 
            newPreContractInfo.Delivered = this._delivered; 
            newPreContractInfo.CurrentSituation = this._currentSituation; 
            newPreContractInfo.BlackDate = this._blackDate; 
            newPreContractInfo.TradeMonth = this._tradeMonth; 
            newPreContractInfo.ModifiedDate = this._modifiedDate; 
            newPreContractInfo.ACRNo = this._aCRNo; 
            newPreContractInfo.ASBorLucent = this._aSBorLucent; 
            newPreContractInfo.Applicant = this._applicant; 
            newPreContractInfo.ApplicantEmail = this._applicantEmail; 
            newPreContractInfo.Principal = this._principal; 
            newPreContractInfo.PrincipalEmail = this._principalEmail; 
            newPreContractInfo.CustomerName = this._customerName; 
            newPreContractInfo.CustomField01 = this._customField01; 
            newPreContractInfo.CustomField02 = this._customField02; 
            newPreContractInfo.CustomField03 = this._customField03; 
            newPreContractInfo.CustomField04 = this._customField04; 
            newPreContractInfo.DeliveryPercent = this._deliveryPercent; 
            newPreContractInfo.AdvancedContract = this._advancedContract; 
            newPreContractInfo.IsRisk = this._isRisk; 
            newPreContractInfo.CATID = this._cATID ; 
            newPreContractInfo.BDID = this._bDID ; 
            newPreContractInfo.ProvinceID = this._provinceID ; 
            newPreContractInfo.ProductID = this._productID ; 
            newPreContractInfo.StatusID = this._statusID ; 
            newPreContractInfo.TypeID = this._typeID ;
            newPreContractInfo.DeliveryDate = this._deliveryDate;
		    newPreContractInfo.Flag = this._flag;
            newPreContractInfo.IsDelay = this._isDelay;

            newPreContractInfo.AdjustID = this._adjustID;
            newPreContractInfo.SparePrice = this._sparePrice;
            newPreContractInfo.CFIPrice = this._cfiPrice;
            newPreContractInfo.DeliveryPlan = this._deliveryPlan;
            newPreContractInfo.UpdateReason = this._updateReason;
            newPreContractInfo.AOGDate = this._aogDate;
            newPreContractInfo.TransferHistoryInfo = this._transferHistoryInfo;
            newPreContractInfo.SpecialApprove = this._specialApprove;
            newPreContractInfo.DeadlineOfTrying = this._deadlineOfTrying;
			return newPreContractInfo;
		}
    }
}



